package com.ccut.lc.service.Impl;

import java.util.List;

import javax.annotation.Resource;

import com.ccut.lc.dao.OrderListMapper;
import com.ccut.lc.model.Order;
import com.ccut.lc.model.ProductType;
import com.ccut.lc.model.QueryVo;
import com.ccut.lc.service.OrderListService;
import com.ccut.lc.utils.Page;
import org.springframework.stereotype.Service;

@Service
public class OrderListServiceImpl implements OrderListService {
	@Resource
	private OrderListMapper orderListMapper;

	@Override
	public void addOrder(Order ol) {
		orderListMapper.addOrder(ol);
	}


	@Override
	public Page<Order> selOrderList(QueryVo queryVo) {
		queryVo.setStart((queryVo.getPage()-1)*queryVo.getRows());
		List<Order> list = orderListMapper.selOrderList(queryVo);
		int total = orderListMapper.getTotal(queryVo);
		Page<Order> page = new Page<>(total,queryVo.getPage(),queryVo.getRows(),list);
		return page;
	}

	@Override
	public List<Order> selOrderList(String uid, String state) {
		return orderListMapper.selOrderList(uid, state);
	}

	@Override
	public Order findOrderByID(Integer id) {
		return orderListMapper.findOrderByID(id);
	}

	@Override
	public void updateOrder(Order order) {
		orderListMapper.updateOrderState(order);
	}

	@Override
	public void deleteOrder(Integer id) {
		orderListMapper.delOrder(id);
	}

}
